package net.zjitc.servlet;

import net.zjitc.domain.Product;
import net.zjitc.service.ProductService;
import net.zjitc.service.impl.ProductServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;

/**
 * Created by hasee on 2017/10/27.
 */
@WebServlet(name = "EditUIServlet",urlPatterns = "/editUIServlet")
public class EditUIServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");

        String pid = request.getParameter("pid");
        String pageNum = request.getParameter("pageNum");
        String condition = request.getParameter("condition");
        ProductService service = new ProductServiceImpl();
        Product product = service.findById(pid);
        request.setAttribute("product",product);
        request.getRequestDispatcher("/product/editproduct.jsp?pageNum="+pageNum+ URLEncoder.encode(condition,"utf-8")).forward(request,response);
    }
}
